import { defineStore } from 'pinia'

export const useConfigStore = defineStore('config', {
  state: () => ({
    isDark: false,
    locale: 'zh-CN',
    sidebarCollapsed: false
  }),
  actions: {
    toggleTheme() {
      this.isDark = !this.isDark
      document.documentElement.classList.toggle('dark', this.isDark)
    },
    setLocale(locale) {
      this.locale = locale
    },
    toggleSidebar() {
      this.sidebarCollapsed = !this.sidebarCollapsed
    }
  },
  persist: {
    key: 'config-store',
    storage: localStorage
  }
})